<?php
	include 'db.php'; //database config and connection	
	$id = $_GET['id'];
	$cartId = $_GET['cartId'];
	$qty = $_GET['qty'];
	if(2 > $qty){
		$sql = "DELETE FROM cart WHERE cartId='$cartId'";
	} else {
		$sql = "update cart set qty = qty - 1 where itemId = '$id'";
	}
	mysql_query($sql);
	header("location:products.php");
?>